<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Sa-Token-SSO-Client端-登录中转页页</title>
		<style type="text/css">
		
		</style>
	</head>
	<body>
		<div class="login-box">
			加载中 ... 
		</div>
		<script src="sso-common.js"></script>
		<script type="text/javascript">
		
			var back = getParam('back', '/');
			var ticket = getParam('ticket');
			
			window.onload = function(){
				if(ticket) {
					doLoginByTicket(ticket);
				} else {
					goSsoAuthUrl();
				}
			}
			
			// 重定向至认证中心 
			function goSsoAuthUrl() {
				ajax('/sso/getSsoAuthUrl', {clientLoginUrl: location.href}, function(res) {
					location.href = res.data;
				})
			}
		
			// 根据ticket值登录 
			function doLoginByTicket(ticket) {
				ajax('/sso/doLoginByTicket', {ticket: ticket}, function(res) {
					localStorage.setItem('satoken', res.data);
					location.href = decodeURIComponent(back); 
				})
			}
			
		</script>
	</body>
</html>
